#include <iostream>
#include <vector>

using namespace std;
class Solution 
{
public:
    int maxArea(vector<int>& height) 
    {
        int left = 0, right = height.size() - 1;
        int m = 0;
        while (left < right)
        {
            int v = min(height[left], height[right]) * (right - left);
            m = max(m, v);

            if (height[left] < height[right])
                left++;
            else
                right--;
        }
        return m;
    }
};

int main()
{
    vector<int> v{ 1,8,6,2,5,4,8,3,7 };
    Solution xz;
    int n = xz.maxArea(v);

    cout << n << endl;

	return 0;
}